package com.xunshibao.core.web;

import javax.servlet.ServletException;

import freemarker.template.Configuration;
import freemarker.template.TemplateModelException;

public class FreemarkerServlet extends freemarker.ext.servlet.FreemarkerServlet {
    /**
	 * 
	 */
    private static final long serialVersionUID = 7043441462322280280L;

    @Override
    public void init() throws ServletException {
        super.init();
        Configuration config = this.getConfiguration();
        try {
            // 添加ctx全局变量
            config.setSharedVariable("ctx", this.getServletContext().getContextPath());
        } catch (TemplateModelException e) {
            e.printStackTrace();
        }
    }

}
